/*
 * To change this template, choose Tools | Templates
 * and open the template in the editor.
 */
package mx.its.dsw2.bibliotecaDao;

import mx.its.dsw2.biblioteca.Modelo.Categoria;
import javax.ejb.Stateless;
import javax.persistence.EntityManager;
import javax.persistence.PersistenceContext;
import javax.persistence.Query;

/**
 *
 * @author Yessy
 */
@Stateless
public class CategoriaDao extends AbstractDao<Categoria> implements CategoriaDaoLocal {
    @PersistenceContext(unitName = "Biblioteca8e-ejbPU")
    private EntityManager em;

    @Override
    protected EntityManager getEntityManager() {
        return em;
    }

    public CategoriaDao() {
        super(Categoria.class);
    }
    @Override
    public boolean findDuplicity(Categoria category){
       
        Query q=em.createNamedQuery("Categoria.findByClave");
       q.setParameter("clave", category.getClave());
        
        return !q.getResultList().isEmpty();
    
    }
}
